package uy.edu.um.ltic.client.gui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;

import java.awt.Font;
import java.util.ArrayList;
import java.util.GregorianCalendar;

import javax.swing.JList;
import javax.swing.UIManager;

import uy.edu.um.ltic.client.communication.EmployeeRemoteClientMgr;
import uy.edu.um.ltic.commons.EmployeeVO;

import javax.swing.JScrollPane;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class ReporteCantidadPalabrasFinal extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private DefaultListModel<NodoEmpleado> listModel = new DefaultListModel<NodoEmpleado>();
	JScrollPane scrollPane = new JScrollPane();
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					//ReporteCantidadPalabrasFinal frame = new ReporteCantidadPalabrasFinal();
					//frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @param fecha1 
	 * @param fecha2 
	 */
	public ReporteCantidadPalabrasFinal(ArrayList<NodoEmpleado> resultado) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				Reportes.getInstance().setVisible(true);
				dispose();
			}
		});
		this.setResizable(false);
		JList<NodoEmpleado> list = new JList<NodoEmpleado>(listModel);
		ArrayList<NodoEmpleado> empleadoNodo = new ArrayList<NodoEmpleado>();
		for (int i=0;i<resultado.size();i++){
			empleadoNodo.add(resultado.get(resultado.size()-1-i));
		}
		for (int i=0;i<empleadoNodo.size();i++){
			listModel.add(i, empleadoNodo.get(i));
		}
		list.setCellRenderer(new MyCellRenderer3());
		setTitle("Persona y cantidad de palabras");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 364);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 399, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(15, Short.MAX_VALUE))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 288, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(85, Short.MAX_VALUE))
		);
		
		
		scrollPane.setViewportView(list);
		
		contentPane.setLayout(gl_contentPane);
	}
}
